import { createRouter, createWebHistory } from 'vue-router'
import store from "../store/store.js";

const disableLoading = () => {
    store.commit('setLoadingDisable', true)
}
const recoveryLoading = () => {
    store.commit('setLoadingDisable', false)
}

const routes = [
    {
        path: '/',
        name: 'Hall',
        component: () => import('../views/Hall.vue'),
        afterEnter: [recoveryLoading]
    },
    {
        path: '/battle',
        name: 'Battle',
        component: () => import('../views/Battle.vue'),
        beforeEnter: [disableLoading]
    }
]

const router = createRouter({
    history: createWebHistory(),
    routes
});

export default router